package main

import (
	"fmt"

	"github.com/go-redis/redis/v7"
)

func main2() {
	// 建立Redis连接
	//ctx := context.Background()
	client := redis.NewClient(&redis.Options{
		Addr:     "192.168.0.248:6379",
		Password: "", // 如果有密码，需要设置
		DB:       0,  // 使用默认数据库
	})

	// 订阅频道
	channel := "/edgex/events/device/Spinning-Device-Modbus-Profile/TestModbus1/BootSpindleSpeed"
	pubsub := client.Subscribe(channel)
	defer pubsub.Close()

	// 接收消息
	for {
		fmt.Println("## Start Received message ###")
		msg, err := pubsub.ReceiveMessage()
		if err != nil {
			fmt.Println("Failed to receive message:", err)
			break
		}

		fmt.Println("Received message:", msg.Payload)
	}
}
